$(document).ready(function(){	
	QB.init(QBPARAMS.app_id, QBPARAMS.auth_key, QBPARAMS.auth_secret);
 
	
	 if (localStorage['auth']) {  		
		storage = JSON.parse($.base64.decode(localStorage['auth']));
		
		
		 $("#email").val(storage.email);
		 $("#password").val(storage.password);

		 if (localStorage['status']) {		 
			 status = JSON.parse($.base64.decode(localStorage['status']));	
			 $("#status").val(status.status); 
		 }
		 
		 if (localStorage['profilePhoto']) {	
			 $("#profileUserPage").spin("modal");
			 profilePhoto = JSON.parse($.base64.decode(localStorage['profilePhoto']));			
			 getQBUserPhoto(storage.email,storage.password,profilePhoto.profilePhoto,"previewUserPhoto",SHOW_USER_PROFILE_PHOTO);
		 }		 
	 }
});
 



$(document).on('click','#updateUserProfileButton',function(){ 
	 console.log("Actualizar Perfil");

	 if (localStorage['auth']) {  		
		storage = JSON.parse($.base64.decode(localStorage['auth']));
		
		if($("#password").val() != storage.password){
			//TODO 
		}
	 }
	 
	 if (localStorage['status']) {		 
		status = JSON.parse($.base64.decode(localStorage['status']));	
		if($("#status").val()!= status.status){
			
		} 
	 }
});

 $(document).on('change','#updateUserPhoto',function(){ 
	 console.log("Selecciono foto");
		var file = $("input[type=file]")[0].files[0];			 
	//	updateUserPhoto('rocamorarubio123@gmail.com','123456789','',file);
		if (localStorage['auth']) {  	
			$("#profileUserPage").spin("modal");
			var file = $("input[type=file]")[0].files[0];			 
			storage = JSON.parse($.base64.decode(localStorage['auth']));			
			updateQBUserPhoto(storage.email,storage.password,storage.scringoId,storage.qbUserId,file,STEP_UPDATE_USER_PROFILE_PHOTO);			 
		 }
		 
});
  
 